<template>
    <div>
        <!-- 头部搜索框 -->
       <van-search v-model="value" placeholder="请输入搜索关键词" />

       <!-- 侧边栏导航 -->
       <div class="classification">
            <van-sidebar v-model="activeKey" >
                    <van-sidebar-item :title="item.name"  v-for="item in sidebar" :key="item.id"  @click="info(item.id)"/>
                </van-sidebar>
                <div class="content-right" v-for="item in content " :key="item.id">
                        <div class="banner">
                                <img :src="item.banner_url" alt="">
                        </div>
                        <div class="content-title"> -{{item.name}}好物- </div>

                        <div class="content-bottom"  >
                                <div class="item" v-for="info in item.subList" :key="info.id" @click="categoryinfo(info)">
                                    <img :src="info.wap_banner_url" alt="">
                                    <p>{{info.name}}</p>
                                </div>
                                
                                <div></div>
                                <div></div>
                               
                        </div>
                </div>
       </div>


    </div>
</template>

<script>
import { listaction, currentaction } from "../../api/category/index.js"
    export default {
        data() {
            return {
                activeKey:0,
                value:"",
                sidebar:[],
                content:[],
              
            }
        },
        methods: {
                info(item) {
                   currentaction({
                    id:item
                   }).then(res=>{
                    //    console.log(res,"获取数据");
                       this.content = res.data
                   })
                },
                categoryinfo(info){
                    // console.log(item);
                    this.$router.push({name:"categoryinfo",query:{item:info}})
                }
               
        },
        created(){
            listaction().then(res=>{
                // console.log(res);
                this.sidebar = res.categoryList
            });
            currentaction({
              id:1005000
                   }).then(res=>{
                    //    console.log(res,"获取数据");
                       this.content = res.data
            })

        }
    }
</script>

<style lang="scss" scoped>
    .classification {
        width: 100%;
        height: 572px;
        display: flex;
        justify-content: space-between;
        background-color: #ffffff;

        .content-right {
            width: 295px;
            height: 100%;
            box-sizing: border-box;
            padding-left: 10px;
            padding-right: 10px;
            .banner {
                width: 100%;
                height: 111px;
                // background-color: red;
                img {
                    width: 100%;
                    height: 100%;
                }
            }
            .content-title {
                width: 100%;
                height: 66px;
                text-align: center;
                box-sizing: border-box;
                padding: 20px;
            }
            .content-bottom {
                width: 100%;
                height: 392px;
                // background-color: red;
                display:flex;
                justify-content: space-between;
                flex-wrap: wrap;;
                align-content: space-around;
                
                
                .item {
                    width: 88px;
                    height: 88px;
                    // background-color: green;
                    img {
                        display: block;
                        width: 72px;
                        height: 72px;
                        margin: 0 auto;
                        // background-color: blue;
                    }
                    p {
                        width: 100%;
                        text-align: center;
                        font-size: 12px;
                        margin: 0;
                       
                       
                    }
                }
            }
        }
    }
</style>